-
-
Notifications
You must be signed in to change notification settings - Fork 195
London | May 2025 | Samuel Tarawally | Sprint 1 | Coursework #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation is very clear. Good job.
I just have a few suggestions and questions.
// Line 3 reassigns the 'count' variable. | ||
// It evaluates the right side first (0 + 1 = 1), and then assigns that result back to the 'count' variable. | ||
// The 'count' variable is often used to keep track of the number of iterations or occurrences in a loop or process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operation like count = count + 1
is very common in programming, and there is a programming term describing such operation.
Can you find out what one-word programming term describes the operation on line 3?
|
||
console.log(`The random number is: ${num}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you describe how the expression at line 4 works?
Can you also describe the possible values that could be assigned to num
using the interval notation ?
[
,]
=> inclusion(
,)
=> exclusion
For example, we can say, "Math.random()
returns a random number in the interval[0, 1)
".
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); | ||
// This line extracts and formats the pence part of the price. | ||
// - It declares a constant variable named `pence`. | ||
// - It uses `substring(paddedPenceNumberString.length - 2)` on `paddedPenceNumberString` ("399"). | ||
// - This extracts the last two characters of the string, which are "99". | ||
// - The `padEnd(2, "0")` method ensures the extracted pence value has at least two digits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we expect this program to work as intended for any valid penceString
if we deleted .padEnd(2, "0")
from the code?
In other words, do we really need .padEnd(2, "0")
in this script?
Learners, PR Template
Self checklist
Changelist